package com.example.Iterator;

public class NameRepository implements Container {
    private String name[] = {"a", "b", "c"};

    @Override
    public Iterator getIterator() {
        return new NameIterator();
    }

    /**
     * 内部类
     */
    public class NameIterator implements Iterator {
        int index = 0;
        @Override
        public boolean hasNext() {
            if (index < name.length)
                return true;
            return false;
        }

        @Override
        public Object next() {
            if (this.hasNext())
                return name[index++];
            return null;
        }
    }
}
